IF EXISTS (SELECT * FROM SYSOBJECTS WHERE ID = OBJECT_ID('PaintingSelectMulti','P'))
    DROP PROCEDURE PaintingSelectMulti
GO
/*
 * Designer:     Kevin
 * Description:    
 * Created:      03/10/2011
 * History:
 * =============================================================================
 * Author      DateTime        Alter Description
 * =============================================================================
 */

CREATE PROCEDURE PaintingSelectMulti
(
	@PaintingNumbers NVARCHAR(1000)
)
AS
BEGIN
	if @PaintingNumbers is null or @PaintingNumbers=''
	begin
		return
	end
	
	declare @TempPainting table(
		PaintingId int,
		PaintingNumber nvarchar(100)
	)

	insert into @TempPainting(
		PaintingNumber
	)
	select Item as PaintingNumber
	from FunStringSplit(@PaintingNumbers, ',')
	
	select 
		tp.PaintingNumber,
		p.Title,
		ISNULL(p.image_url, '') as ImageUrl
	from @TempPainting tp
	inner join painting p on tp.PaintingNumber=p.painting_number
END
GO